#!/usr/bin/env python
# -*- coding: utf-8 -*-
#Intesim Python Script

gl.Table('dt4e')
table = gl.tables['dt4e']
table.interpolationType = InterpolationType.Linear
table.extrapolationType = ExtrapolationType.BHType2
table.argument = 'H'
table.outPutName = 'B'
table.setData( ( 0, 238.7, 318.3, 358.1, 437.7, 477.5, 636.6, 795.8, 1114.1, 1273.2, 1591.5, 2228.2, 3183.1, 4774.6, 6366.2, 7957.7, 15915.5, 31831, 47746.5, 63662, 79577.5, 159155, 318310, ), ( 0, 0.2003, 0.3204, 0.40045, 0.50055, 0.5606, 0.7908, 0.931, 1.1014, 1.2016, 1.302, 1.4028, 1.524, 1.626, 1.698, 1.73, 1.87, 1.99, 2.04, 2.07, 2.095, 2.2, 2.4, ) )
gl.loadMaterial('air')
gl.materials['air'].removeValue(MaterialProperty.AdvancedDensityType)
gl.materials['air'].removeValue(MaterialProperty.BoussinesqDensity)
gl.materials['air'].removeValue(MaterialProperty.ThermalExpansionCoefficient)
gl.materials['air'].removeValue(MaterialProperty.MolecularWeight)
gl.materials['air'].addType(MaterialType.Thermal)
gl.materials['air'].setValue(MaterialProperty.KZZ, ValueType.Value,  26.24)
gl.materials['air'].setValue(MaterialProperty.KYY, ValueType.Value,  26.24)
gl.materials['air'].setValue(MaterialProperty.KXX, ValueType.Value,  26.24)
gl.materials['air'].setValue(MaterialProperty.HCAPACITY, ValueType.Value,  1012000000)
gl.materials['air'].removeType(MaterialType.IronLoss)
gl.Material('dt4e')
gl.materials['dt4e'].addType(MaterialType.Magnetic_MUR)
gl.materials['dt4e'].setValue(MaterialProperty.MURX, ValueType.Table,  1)
gl.materials['dt4e'].setValue(MaterialProperty.MURY, ValueType.Table,  1)
gl.materials['dt4e'].setValue(MaterialProperty.MURZ, ValueType.Table,  1)
gl.materials['dt4e'].setValue(MaterialProperty.Density, ValueType.Value,  2e-07)
gl.materials['dt4e'].removeType(MaterialType.IronLoss)
gl.materials['dt4e'].value(MaterialProperty.Density).value = 2e-07
gl.materials['dt4e'].addType(MaterialType.Thermal)
gl.materials['dt4e'].setValue(MaterialProperty.KZZ, ValueType.Value,  20000)
gl.materials['dt4e'].setValue(MaterialProperty.KYY, ValueType.Value,  20000)
gl.materials['dt4e'].setValue(MaterialProperty.KXX, ValueType.Value,  20000)
gl.materials['dt4e'].setValue(MaterialProperty.HCAPACITY, ValueType.Value,  460000000)
gl.materials['dt4e'].setValue(MaterialProperty.Density, ValueType.Value,  7.5e-06)
gl.Material('coil')
gl.materials['coil'].addType(MaterialType.Thermal)
gl.materials['coil'].setValue(MaterialProperty.KZZ, ValueType.Value,  380000)
gl.materials['coil'].setValue(MaterialProperty.KYY, ValueType.Value,  380000)
gl.materials['coil'].setValue(MaterialProperty.KXX, ValueType.Value,  380000)
gl.materials['coil'].setValue(MaterialProperty.HCAPACITY, ValueType.Value,  380000000)
gl.materials['coil'].addType(MaterialType.Electro_RSV)
gl.materials['coil'].setValue(MaterialProperty.RSVZ, ValueType.Value,  0.00019025)
gl.materials['coil'].setValue(MaterialProperty.RSVY, ValueType.Value,  0.00019025)
gl.materials['coil'].setValue(MaterialProperty.RSVX, ValueType.Value,  0.00019025)
gl.materials['coil'].addType(MaterialType.Magnetic_MUR)
gl.materials['coil'].setValue(MaterialProperty.MURX, ValueType.Value,  1)
gl.materials['coil'].setValue(MaterialProperty.MURY, ValueType.Value,  1)
gl.materials['coil'].setValue(MaterialProperty.MURZ, ValueType.Value,  1)
gl.materials['coil'].setValue(MaterialProperty.Density, ValueType.Value,  8.95e-06)
Model.updateSolverList()
Model.updateSolverList()
Model.Model('model_1')
Model.models['model_1'].typeName = 'Magnetic'
Model.models['model_1'].importComponent('extrusion')
Model.models['model_1'].importComponent('cylinder')
component = Model.models['model_1'].componentList.at(0)
component.elementType = 'MAGNETIC_Tet10'
component.emagForceOutput = 1
component.emagForceCalculation = 2
Mesh.setComponentToElemType('extrusion')
component = Model.models['model_1'].componentList.at(1)
component.elementType = 'MAGNETIC_Tet10'
component.emagForceOutput = 1
component.emagForceCalculation = 2
Mesh.setComponentToElemType('cylinder')
Model.models['model_1'].componentList.at(0).materialId = 4
Model.models['model_1'].componentList.at(1).materialId = 4
holeDataList = []
Mesh.createSharedTopoMeshBand(listFullName = ['cylinder.Solid1', 'extrusion.Solid1'], additionGeomList = [], bandFullName = [], holeList = holeDataList, bandMotionType = 0, sharedTopoMeshType = 3, elemType = 'ETri', order = 2, higherNodesOfType = 1, tolerance = 0)
Model.solvePhysicsModel('model_1')
Model.solvePhysicsModel('model_1')
Post.setView('ElementView')
Model.updateSolverList()
Post.openPostWindow('D:/softwareplaytation/electromagnetic/3D/coil/coil3d.model_1.model.res/coil3d.model_1.model_model_1_em_0001.res.inp', 'model_1')
vector_plot = Post.newVector('model_1')
vector_plot.name = 'Magnetic Flux Density'
vector_plot.dataAdapterID = 40
vector_plot.appendCompId( 1) 
vector_plot.appendCompId( 2) 
vector_plot.setDraw(True)
vector_plot.min = 0
vector_plot.max = 0
vector_plot.length = 400
vector_plot.dataCount = 12
vector_plot.location = 0
vector_plot.setAutoPosition(True)
vector_plot.hideoutrange = False
vector_plot.show()
del vector_plot
gl.CoordSystem()
gl.coordSystems['gartesian_1'].type =  CSYSType.RotationalAxis
gl.coordSystems['rotationalaxis_1'].setPoint( 0, 0, 0, 0 )
gl.coordSystems['rotationalaxis_1'].setPoint( 1, 0, 0, 1 )
gl.coordSystems['rotationalaxis_1'].setPoint( 2, 0, 0, 0 )
bc = Model.BoundaryCondition()
bc.type = 'SourceCurrentDensity'
bc.compId = 1
bc.value('JSX').value = 0
bc.value('JSX').type = ValueType.Value
bc.value('JSY').value = 1000
bc.value('JSY').type = ValueType.Value
bc.value('JSZ').value = 0
bc.value('JSZ').type = ValueType.Value
Model.models['model_1'].bcList.append(bc)
Model.solvePhysicsModel('model_1')
Post.updateResult('D:/softwareplaytation/electromagnetic/3D/coil/coil3d.model_1.model.res/coil3d.model_1.model_model_1_em_0001.res.inp','model_1')
vector_plot = Post.newVector('model_1')
vector_plot.name = 'Magnetic Flux Density'
vector_plot.dataAdapterID = 40
vector_plot.appendCompId( 1) 
vector_plot.appendCompId( 2) 
vector_plot.setDraw(True)
vector_plot.min = 0.12494
vector_plot.max = 6839.07
vector_plot.length = 400
vector_plot.dataCount = 12
vector_plot.location = 0
vector_plot.setAutoPosition(True)
vector_plot.hideoutrange = False
vector_plot.show()
del vector_plot
